#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:2_school_calendar_week.py
# author:张世航
# datetime:2024/11/9 22:29
# software: PyCharm
"""
this is function  description 
"""
# import module your need


# 2 定义一个函数，判断一个输入的日期，是当年的第几周，周几？  将程序改写一下，能针对我们学校的校历时间进行计算（校历第1周，2月17-2月23；校历第27周，8月17-8月23；）；
#
import datetime

def week_of_year(date):
    """判断输入日期是当年的第几周，周几"""
    week_number = date.isocalendar()[1]
    weekday = date.strftime("%A")  # 获取星期几
    return week_number, weekday

# 校历计算
def school_calendar_week(date):
    """根据校历计算周数"""
    start_date = datetime.date(date.year, 2, 17)  # 校历第1周开始
    week_number = (date - start_date).days // 7 + 1
    return week_number

# 输入日期
input_date = input("请输入日期 (YYYY-MM-DD): ")
date = datetime.datetime.strptime(input_date, "%Y-%m-%d").date()
week_num, weekday = week_of_year(date)
school_week = school_calendar_week(date)

print(f"当年的第 {week_num} 周，星期 {weekday}")
print(f"校历第 {school_week} 周")